import request from "@/utils/request";
import {MenuQuery, MenuVO, MenuForm, RouteVO} from "./model";

class MenuAPI {
    /**
     * 获取路由列表
     */
    static getRoutes() {
        return request<any, ApiResult>({
            url: "/api/sysMenu/listTree",
            method: "post",
        });
    }

    /**
     * 获取菜单树形列表
     *
     * @param queryParams
     */
    static getList(queryParams: MenuQuery) {
        return request<any, ApiResult>({
            url: "/api/sysMenu/listTree",
            method: "post",
            data: queryParams,
        });
    }

    /**
     * 获取菜单下拉数据源
     */
    static getOptions() {
        return request<any, ApiResult>({
            url: "/api/sysMenu/listMenuOptions",
            method: "post",
        });
    }


    /**
     * 添加菜单
     *
     * @param data
     */
    static add(data: MenuForm) {
        return request({
            url: "/api/sysMenu/add",
            method: "post",
            data: data,
        });
    }

    /**
     * 修改菜单
     *
     * @param id
     * @param data
     */
    static update(data: MenuForm) {
        return request({
            url: "/api/sysMenu/update",
            method: "post",
            data: data,
        });
    }

    /**
     * 删除菜单
     *
     * @param id 菜单ID
     */
    static deleteById(id: number) {
        return request({
            url: "/api/sysMenu/delete",
            method: "post",
            data: {id: id}
        });
    }

    static refreshCache() {
        return request({
            url: "/api/sysMenu/refreshCache",
            method: "post"
        });
    }
}

export default MenuAPI;
